import {
  network
} from '../../utils/network.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let _this = this;
    let type = options.type;
    let title = '';
    if (type == "movies") {
      network.getMovieList({
        count: 100,
        success(movies) {
          _this.setData({
            items: movies
          })
        },
        err(err) {
          console.log(err)
        }
      })
      title = '电影'
    } else if (type == "tv") {
      network.getTvList({
        count: 100,
        success(tvlist) {
          _this.setData({
            items: tvlist
          })
        },
        err(err) {
          console.log(err)
        }
      })
      title = '电视剧'
    } else if (type == "show") {
      network.getShowList({
        count: 100,
        success(showList) {
          _this.setData({
            items: showList
          })
        },
        err(err) {
          console.log(err)
        }
      })
      title = '综艺'
    }
    wx.setNavigationBarTitle({
      title: title,
    })
    _this.setData({
      types:type
    })
  },

})